package com.lakeworks.processor.base;

import com.lakeworks.common.domain.base.event.TicketEvent;
import com.lakeworks.domain.TktProcess;
import org.slf4j.Logger;

import static org.slf4j.LoggerFactory.getLogger;

public abstract class AbstractTicketProcessor<E extends TicketEvent> extends AbstractIssueProcessor<E> implements TicketProcessor<E> {

    protected final Logger logger = getLogger(getClass());

    @Override
    public TktProcess apply(
            E event
    ) {
        var process = super.apply(event);
        if (event.getTicket() != null) {
            process.setTicket(event.getTicket());
            process.setVersion(event.getTicket().getVersion() + 1);
        }
        return process;
    }
}
